package com.gitee.wsl.android.ui.recyclerView.adapter.viewholder.viewbind

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
//import androidx.viewbinding.ViewBinding
import com.gitee.wsl.android.ui.recyclerView.adapter.ActionRepository
import com.gitee.wsl.android.ui.recyclerView.adapter.viewholder.Subscriber
import com.gitee.wsl.android.ui.recyclerView.adapter.viewholder.ViewHolderBindAction
import com.gitee.wsl.android.ui.recyclerView.adapter.viewholder.ViewHolderConfig
import com.gitee.wsl.android.ui.recyclerView.adapter.viewholder.ViewHolderFactory

/*
open class DefaultBindingViewHolder<T : Any,AR: ActionRepository<T>,VIEW_BIND: ViewBinding>(val bindingView: VIEW_BIND, val callHandler: ViewHolderBindAction<T, AR, VIEW_BIND>) : RecyclerView.ViewHolder(bindingView.root),
    Subscriber<T, AR> {

    override fun onBindViewHolder(position: Int,payloads: List<Any>,item:T?,config: ViewHolderConfig<T, AR>) {
        callHandler.onBindViewHolder(bindingView,position, payloads,item,config)
    }

    override fun unBindViewHolder(position: Int) {
        callHandler.unBindViewHolder(itemView,position)
    }

    override fun onViewAttachedToWindow(holder: RecyclerView.ViewHolder, position: Int) {
        callHandler.onViewAttachedToWindow(this,position)
    }

    override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder, position: Int) {
        callHandler.onViewDetachedFromWindow(this,position)
    }
}

open class DefaultBindingViewHolderFactoryImp<T : Any, AR : ActionRepository<T>,BIND_VIEW: ViewBinding>(val type: Int, val createHolder: (inflater: LayoutInflater, root: ViewGroup, attachToRoot: Boolean) -> BIND_VIEW, val bindCallbacks: ViewHolderBindAction<T,AR,BIND_VIEW>) :
    ViewHolderFactory<DefaultBindingViewHolder<T, AR, BIND_VIEW>> {

    fun createViewHolder(parent: ViewGroup, layoutInflater: LayoutInflater): BIND_VIEW {
        return createHolder(layoutInflater,parent,false)
    }

    override fun getSupportType(): Int = type

    override fun getViewHolder(
        parent: ViewGroup,
        layoutInflater: LayoutInflater
    ): DefaultBindingViewHolder<T, AR, BIND_VIEW> {
        val bindingView = createViewHolder(parent,layoutInflater)
        return DefaultBindingViewHolder(bindingView,bindCallbacks)
    }

}*/
